package com.shang.web.reactor8;

import java.util.Observable;

/**
 * @ClassName ObvserverDemo
 * @Description 观察者模式
 * @Author Larry
 * @Date 2021/5/25 17:31
 * @Version 1.0
 */
public class ObvserverDemo extends Observable {

    public static void main(String[] args) {
        ObvserverDemo demo = new ObvserverDemo();

        demo.addObserver((o,arg) -> {
            System.out.println("发生变化");
        });
        demo.addObserver((o,arg) -> {
            System.out.println("收到被观察者通知准备变化");
        });

        demo.setChanged();
        demo.notifyObservers();//通知
    }

}
